Skip to content

HIVE-29778: Log the effective user when creating a Hive session handle - #6657

Open
owenmonn wants to merge 1 commit into
apache:masterfrom
owenmonn:HIVE-29778
Open

HIVE-29778: Log the effective user when creating a Hive session handle#6657
owenmonn wants to merge 1 commit into
apache:masterfrom
owenmonn:HIVE-29778

Conversation

@owenmonn

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

ThriftCLIService#getSessionHandle now logs the resolved userName parameter instead of req.getUsername().

Why are the changes needed?

req.getUsername() is the raw TOpenSessionReq field, which the Hive JDBC driver only populates when auth=noSasl. Under Kerberos, LDAP/SASL PLAIN and HTTP transport the identity arrives via the SASL authorization ID or a thread-local, so the line logs Creating Hive session handle for user [null] from IP <ip>.

The userName parameter is the resolved effective user that is actually passed to CLIService#openSession / #openSessionWithImpersonation.

Does this PR introduce any user-facing change?

No functional change. The log line now shows the effective user instead of null.

How was this patch tested?

No new tests; log message change only.

req.getUsername() is only populated when auth=noSasl, so the log read
"user [null]" under Kerberos, LDAP/SASL PLAIN and HTTP transport. Use the
resolved userName parameter that is passed to openSession instead.
final String ipAddress = getIpAddress();

LOG.info("Creating Hive session handle for user [{}] from IP {}", req.getUsername(), ipAddress);
LOG.info("Creating Hive session handle for user [{}] from IP {}", userName, ipAddress);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't we do if req.getUsername() is null then log userName

@owenmonn owenmonn Jul 29, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That fallback already exists in getUserName(), in the opposite direction:

if (userName == null) {
  userName = req.getUsername();
}

So adding a null check would only change behaviour when both are set, and there the raw value wins and we lose the shortname handling and the getProxyUser() result.

Whereas getUserName() is documented as "Returns the effective username", and that value is what the session is opened with.

@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants